<?php
/****************************/
// Image helper
// thaodx@gmail.com
/****************************/

function getThumbnail($size, $src){
	$imageSize = array('460x460', '150x150');
	$arrSize = explode('x', $size);
	$width = intval($arrSize[0]);
	$height = intval($arrSize[1]);
	$return = $src;
	if(!in_array($size, $imageSize)) return $src;
	if((strstr($src, 'http://') || strstr($src, 'https://')) && strstr($src, 'googleusercontent')){
		if($size == '150x150'){
			$return = preg_replace('/(.+)\/(.+)\.(.+)$/is', '$1/w'.$width.'/$2.$3', $src);
		}
		else{
			$return = preg_replace('/(.+)\/(.+)\.(.+)$/is', '$1/s0/$2.$3', $src);
		}
	}
	else{
		$return = FARM_URL.$size.'/'.$src;
	}
	return $return;
}
function getImage($src){
	$return = $src;
	if((strstr($src, 'http://') || strstr($src, 'https://')) && strstr($src, 'googleusercontent')){
		$return = preg_replace('/(.+)\/(.+)\.(.+)$/is', '$1/s0/$2.$3', $src);
	}
	else{
		$return = FARM_URL.'/'.$src;
	}
	return $return;
}